#!/usr/bin/env python
# encoding: utf-8
import os
import glob
from PIL import Image
import base64
from io import BytesIO
import matplotlib.pyplot as plt

# picture_dir=os.path.join(os.getcwd(),'*.jpg')
# for jpgfile in glob.glob(picture_dir):
#     #encode()
#     jpgfile = r'C:\Users\bingwa\Desktop\zhongnan\2020-12-0720201207175352.jpg'
#     file = open(jpgfile,'rb')
#     base64_data = base64.b64encode(file.read())
#     #decode()
#     byte_data = base64.b64decode(base64_data)
#     image_data = BytesIO(byte_data)
#     img = Image.open(image_data)
#     #show pioture
#     plt.imshow(img)
#     plt.show()

if __name__ == '__main__':
    jpgfile = r'C:\Users\bingwa\Desktop\zhongnan\2020-12-0720201207175352.jpg'
    file = open(jpgfile, 'rb')
    base64_data = base64.b64encode(file.read())
    # decode()
    byte_data = base64.b64decode(base64_data)
    image_data = BytesIO(byte_data)
    img = Image.open(image_data)
    # show pioture
    plt.imshow(img)
    plt.show()
